package com.yn.service.zy.model.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yn.common.constants.Constants;
import com.yn.common.enums.AuditStatusEnum;
import com.yn.common.model.zy.TCareforInfoDO;
import com.yn.common.utils.BeanUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.ObjectUtils;

import java.util.Date;

/**
 * @ClassName: TCareforInfoDTO
 * @Description:
 * @Author: lxp
 * @Date: 2025/5/9 11:38
 **/
@Data
@ApiModel("陪护出参")
public class TCareforInfoDTO {
    @ApiModelProperty("主键Id")
    private Integer id;

    @ApiModelProperty("陪护项目")
    private String carefoProject;

    @ApiModelProperty("图片列表展示缩率图")
    private String imageUrl;

    @ApiModelProperty("陪护简介")
    private String carefoIntro;

    @ApiModelProperty("价格")
    private Integer carefoPrice;

    @ApiModelProperty("电话")
    private String carefoPhoneNumber;

    @ApiModelProperty("审核状态")
    private Integer auditStatus;

    @ApiModelProperty("审核状态字符")
    private String auditStatusStr;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = Constants.DATE_FORMAT)
    private Date createTime;

    public static TCareforInfoDTO transform(TCareforInfoDO tCareforInfoDO){
        if (ObjectUtils.isEmpty(tCareforInfoDO)) {
            return null;
        }

        TCareforInfoDTO tCareforInfoDTO = BeanUtils.copyProperties(tCareforInfoDO, TCareforInfoDTO.class);

        if (!ObjectUtils.isEmpty(tCareforInfoDTO.getAuditStatus())) {
            AuditStatusEnum auditStatusEnum = AuditStatusEnum.getByCode(tCareforInfoDTO.getAuditStatus());
            if (!ObjectUtils.isEmpty(auditStatusEnum)) {
                tCareforInfoDTO.setAuditStatusStr(auditStatusEnum.getName());
            }
        }

        return tCareforInfoDTO;
    }
}
